<?php

namespace App\Http\Services;

use Illuminate\Support\Facades\Log;

class CommonRoomMsgServices extends CommonServices
{
    /**
     * @var RoomMsgServices
     */
    protected $serviceRoomMsg;

    /**
     * 构造函数
     */
    public function __construct()
    {
        $this->serviceRoomMsg = new RoomMsgServices();
    }

    /**
     * 发送公屏消息
     *
     * @param int $roomId 房间id
     * @param array $message 信息
     * $message demo:
     * $messages = [
        ['content' => '内容', 'color' => '颜色', 'bold' => false/true,], bold=是否加粗
        ['content' => '内容', 'color' => '颜色', 'bold' => false/true,], bold=是否加粗
        ]
     *
     * @param string $template 模板,demo:'运气爆棚！恭喜{{#0}}成功开出了福袋礼物 获得{{#1}} 并额外获得彩蛋礼物 {{#2}}'
     */
    public function sendCommonMsg(int $roomId, array $message, string $template)
    {
        $data = [
            'k' => 40001,
            'room_id' => $roomId,
            'm' => $message,
            't' => $template,
        ];

        $this->serviceRoomMsg->send_room_msg($roomId, $data);
    }

    /**
     * 发送房间消息
     *
     * Created at 2021/10/28 17:29
     * @Author <yuxiang.zhu@asiainnovations.net>
     * @param int $roomId
     * @param int $k
     * @param array $data
     */
    public function sendRoomMsg(int $roomId, int $k, array $data = [])
    {
        $data = array_merge($data, ['k' => $k]);
        $this->serviceRoomMsg->send_room_msg($roomId, $data);
    }
}